﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GA.Shared.Interfaces;
using System.Windows;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Windows.Data;
using GA.Server.DatabaseManager;
using GA.Shared.Objects;

namespace GA.Server.Objects
{
    public class DatabasePlayer : DatabaseObject
    {
        /// <summary>
        /// Identifies the Id Property
        /// </summary>
        public static readonly DependencyProperty IdProperty =
            DependencyProperty.Register(
                "Id",
                typeof(int),
                typeof(DatabasePlayer),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the GameId Property.
        /// </summary>
        public static readonly DependencyProperty GameIdProperty =
            DependencyProperty.Register(
                "GameId",
                typeof(int),
                typeof(DatabasePlayer),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the Name Property.
        /// </summary>
        public static readonly DependencyProperty NameProperty =
            DependencyProperty.Register(
                "Name",
                typeof(string),
                typeof(DatabasePlayer),
                new PropertyMetadata(string.Empty));

        /// <summary>
        /// Identifies the AgencyId Property.
        /// </summary>
        public static readonly DependencyProperty AgencyIdProperty =
            DependencyProperty.Register(
                "AgencyId",
                typeof(int?),
                typeof(DatabasePlayer),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the Agency Property.
        /// </summary>
        public static readonly DependencyProperty AgencyProperty =
            DependencyProperty.Register(
                "Agency",
                typeof(Agency),
                typeof(DatabasePlayer),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifes the Characters Property.
        /// </summary>
        public static readonly DependencyProperty CharactersProperty =
            DependencyProperty.Register(
                "Characters",
                typeof(ObservableCollection<Character>),
                typeof(DatabasePlayer),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the Currency Property.
        /// </summary>
        public static readonly DependencyProperty CurrencyProperty =
            DependencyProperty.Register(
                "Currency",
                typeof(int),
                typeof(DatabasePlayer),
                new PropertyMetadata(0));

        /// <summary>
        /// Identifies the Items Property.
        /// </summary>
        public static readonly DependencyProperty ItemsProperty =
            DependencyProperty.Register(
                "Items",
                typeof(ObservableCollection<Item>),
                typeof(DatabasePlayer),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the Permissions Property.
        /// </summary>
        public static readonly DependencyProperty PermissionsProperty =
            DependencyProperty.Register(
                "Permissions",
                typeof(ObservableCollection<Permission>),
                typeof(DatabasePlayer),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the UserId Property.
        /// </summary>
        public static readonly DependencyProperty UserIdProperty =
            DependencyProperty.Register(
                "UserId",
                typeof(int),
                typeof(DatabasePlayer),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the User Property.
        /// </summary>
        public static readonly DependencyProperty UserProperty =
            DependencyProperty.Register(
                "User",
                typeof(User),
                typeof(DatabasePlayer),
                new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the Id.
        /// </summary>
        
        [DatabaseField("Id", IsKey = true, IsIdentity = true)]
        public int Id
        {
            get { return (int)SafeGetValue(IdProperty); }
            set { SafeSetValue(IdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Game Id.
        /// </summary>
        
        [DatabaseField("GameId", IsKey = true)]
        public int GameId
        {
            get { return (int)SafeGetValue(GameIdProperty); }
            set { SafeSetValue(GameIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Name.
        /// </summary>
        
        [DatabaseField("Name", IsKey = true, IsQuoted = true)]
        public string Name
        {
            get { return (string)SafeGetValue(NameProperty); }
            set { SafeSetValue(NameProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Agency Id.
        /// </summary>
        
        [DatabaseField("AgencyId")]
        public int? AgencyId
        {
            get { return (int?)SafeGetValue(AgencyIdProperty); }
            set { SafeSetValue(AgencyIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Agency.
        /// </summary>
        
        public Agency Agency
        {
            get { return (Agency)SafeGetValue(AgencyProperty); }
            set { SafeSetValue(AgencyProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Characters.
        /// </summary>
        
        public ObservableCollection<Character> Characters
        {
            get { return (ObservableCollection<Character>)SafeGetValue(CharactersProperty); }
            set { SafeSetValue(CharactersProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Currency.
        /// </summary>
        
        [DatabaseField("Currency")]
        public int Currency
        {
            get { return (int)SafeGetValue(CurrencyProperty); }
            set { SafeSetValue(CurrencyProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Items.
        /// </summary>
        
        public ObservableCollection<Item> Items
        {
            get { return (ObservableCollection<Item>)SafeGetValue(ItemsProperty); }
            set { SafeSetValue(ItemsProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Permissions.
        /// </summary>
        
        public ObservableCollection<Permission> Permissions
        {
            get { return (ObservableCollection<Permission>)SafeGetValue(PermissionsProperty); }
            set { SafeSetValue(PermissionsProperty, value); }
        }

        /// <summary>
        /// Gets or sets the User Id.
        /// </summary>
        
        [DatabaseField("UserId")]
        public int UserId
        {
            get { return (int)SafeGetValue(UserIdProperty); }
            set { SafeSetValue(UserIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the User.
        /// </summary>
        
        public User User
        {
            get { return (User)SafeGetValue(UserProperty); }
            set { SafeSetValue(UserProperty, value); }
        }

        public DatabasePlayer()
        {
        }

        public DatabasePlayer(Player baseObject)
            : base(baseObject)
        {
        }

        public DatabasePlayer(LinkedDependencyObject baseObject, BindingMode bindingMode)
            : base(baseObject, bindingMode)
        {
        }


        public override void LoadAllPropertyObjects()
        {
            #warning Not Implemented
        }

        public override void LoadPropertyObject(string propertyName)
        {
            #warning Not Implemented
        }
    }
}
